function fn(timer: number) {
    let i = 0;
    return function (target: any, descriptor: any) {
        descriptor.value = function () {
            if (i >= timer) {
                throw new Error(`报错`);
            } 
            i++;
        };
        target()
    };
}

@fn(3)
function myFunction() {
    console.log("执行装饰器");
}

for (let i = 0; i < 4; i++) {
    myFunction();
}